<template>
	<view>
		<view class="mask" v-if="show" @click="close"></view>
		<view class="popup" v-if="show">
			<view class="title">价格日历</view>
			<view class="iconfont icon-guanbi _pos-abs _right _pad-x-20" style="top: 30rpx;" @click="close"></view>
			<view class="min">
				<view class="calendar" style="box-shadow: 0rpx 8rpx 5rpx -4rpx rgba(0, 0, 0, 0.1);">
					<view class="ca-top" v-for="item in textList" :key="item">{{item}}</view>
				</view>
				<scroll-view scroll-y="true" style="height: 65vh;">
					<view class="calendar" v-for="(item,index) in data" :key="index">
						<view class="cabg">{{item.month}}</view>
						<view class="date-title">{{item.year}}年{{item.month}}月</view>
						<view class="date-item" v-for="it in item.day[0].week" :key="it"></view>
						<view class="date-item" v-for="items in item.day" :key="item" :class="`${startTime==items.stamp||endTime==items.stamp?'text':''}`+`${items.stamp>startTime&&items.stamp<endTime?'text':''}`">
							<view class="day" :style="items.stamp<time?'color:#D1CECE;':''">{{items.day}}</view>
							<view class="_font-10" style="line-height: 30rpx;" v-if="items.stamp>=time">￥{{items.price}}</view>
							<view class="_font-10" style="height: 30rpx;" v-else></view>
						</view>
					</view>
					<view style="width: 100%;height: 60rpx;"></view>
				</scroll-view>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		props: {
			show: {
				type: Boolean,
				default: false,
			},
			data: {
				type: Array,
				default: [],
			},
			startTime: {
				type: Number,
				default: 0,
			},
			endTime: {
				type: Number,
				default: 0,
			}
		},
		data() {
			return {
				textList: ['日', '一', '二', '三', '四', '五', '六'],
				time: 0,
			}
		},
		created() {
			let date = new Date();
			let year = date.getFullYear();
			let month = date.getMonth();
			let day = date.getDate();
			this.time = new Date(year,month,day).getTime();
		},
		methods: {
			close(){
				this.$emit('close','')
			}
		}
	}
</script>

<style scoped lang="scss">
	.text {
		background: linear-gradient(-88.58deg,var(--theme-color-left),var(--theme-color-right));
		color: #ffffff;
		border-radius: 8rpx;
	}
	.popup {
		width: 100%;
		position: fixed;
		background-color: #ffffff;
		height: 80vh;
		bottom: 0;
		z-index: 889;
		border-top-left-radius: 30rpx;
		border-top-right-radius: 30rpx;
	}
	.title {
		font-size: 28rpx;
		color: #000000;
		text-align: center;
		margin-top: 30rpx;
	}
	.min {
		margin-top: 10rpx;
	}
	.calendar {
		display: flex;
		flex-wrap: wrap;
		flex-direction: row;
		align-items: center;
		width: 100vw;
		position: relative;
	}
	.ca-top {
		width: 14.2vw;
		display: flex;
		justify-content: center;
		align-items: center;
		height: 66rpx;
		z-index: 10;
	}
	.cabg {
		display: flex;
		justify-content: center;
		width: 100vw;
		font-size: 290rpx;
		color: #f4f5f7;
		position: absolute;
		z-index: 9;
		top: 190rpx;
	}
	.mask {
		position: fixed;
		top: 0;
		left: 0;
		right: 0;
		bottom: 0;
		background-color: rgba(0, 0, 0, 0.65);
		z-index: 888;
	}
	.date-title {
		text-align: center;
		width: 100%;
		font-weight: 800;
		font-size: 30rpx;
		margin-top: 30rpx;
	}
	.date-item-empty {
		width: 14.2vw;
		z-index: 10;
		text-align: center;
		margin-top: 30rpx;
	}
	.date-item {
		width: 14.2vw;
		z-index: 10;
		text-align: center;
		margin-top: 30rpx;
	}
	.day {
		font-size: 34rpx;
		line-height: 50rpx;
	}
</style>
